package org.jeecg.modules.Inventory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.Inventory.entity.Inventory;
import org.jeecg.modules.Inventory.mapper.InventoryMapper;
import org.jeecg.modules.Inventory.service.IInventoryService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 库存表
 * @Author: jeecg-boot
 * @Date:   2024-06-26
 * @Version: V1.0
 */
@Service
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory> implements IInventoryService {

    @Override
    public Inventory getBySkuAndLocation(String sku, String location) {
        LambdaQueryWrapper<Inventory> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Inventory::getSkuCode, sku);
        wrapper.eq(Inventory::getLocation, location);
        return getOne(wrapper);
    }

    @Override
    public List<Inventory> getBySku(String sku) {
        LambdaQueryWrapper<Inventory> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Inventory::getSkuCode, sku);
        return list(wrapper);
    }
}
